package com.dyit.springcloud.hospital.plan.job;

import com.dyit.springcloud.hospital.domain.entity.AppointPlan;
import com.dyit.springcloud.hospital.plan.dao.IApDao;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.quartz.QuartzJobBean;
import sun.rmi.runtime.Log;

import java.util.List;

public class AppQuartz extends QuartzJobBean {

    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private IApDao dao;
    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        List<AppointPlan> list = dao.findAll();
        System.out.println(list);
        for (AppointPlan appointPlan:list){
            String key = appointPlan.getTime()+"$"+appointPlan.getDoctor().getId();
            redisTemplate.opsForValue().set(key,appointPlan.getNum()+"");
        }

        System.out.println("预约导入成功");
    }
}
